package com.zhanghe.study.study_scala.generic

/**
 * 上界测试
 * @author zh
 * @date 2021/5/19 10:08
 */
object TestUpper {

  def main(args: Array[String]): Unit = {
    def test[T <: Parent](obj:T) = {
      obj.name()
    }

    val parent:Parent = new Parent
    //我是父类
    test(parent)

    val child:Child = new Child
    //我是子类
    test(child)
  }
  class Parent{
    def name() = {
      println("我是父类")
    }
  }

  class Child extends Parent {
    override def name() = {
      println("我是子类")
    }
  }
}


